package com.sunnada.edu.business.group.dao;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.stereotype.Repository;

import com.sunnada.edu.system.pub.dao.BaseDaoImpl;

@Repository
public class GroupDaoImpl extends BaseDaoImpl implements GroupDao {

	@Override
	public int getGroupCots(HashMap<String, String> params) {
		List list = selectList("group_sqlmap.getGroupCots", params);
		if (list != null && list.size() > 0) {
			String cot = ((Map) list.get(0)).get("COT") + "";
			return Integer.valueOf(cot);
		}
		return 0;
	}

	@Override
	public List<?> findGroups(HashMap<String, String> params) {
		return selectList("group_sqlmap.findGroups", params);
	}

	@Override
	public int groupDelete(HashMap<String, String> params) {
		return delete("group_sqlmap.groupDelete", params);
	}

	@Override
	public int groupAdd(HashMap<String, String> params) {
		return insert("group_sqlmap.groupAdd", params);
	}

	@Override
	public int groupUpdate(HashMap<String, String> params) {
		return update("group_sqlmap.groupUpdate", params);
	}

	@Override
	public Map getGroupByRecId(HashMap<String, String> params) {
		List list = selectList("group_sqlmap.getGroupByRecId", params);
		if (list != null && list.size() > 0) {
			return (Map) list.get(0);
		}
		return null;
	}

	@Override
	public Map<String, String> getGroup(HashMap<String, String> params) {
		List list = selectList("group_sqlmap.getGroup", params);
		if (list != null && list.size() > 0) {
			return (Map) list.get(0);
		}
		return null;
	}

	@Override
	public int groupEnable(HashMap<String, String> params) {
		return update("group_sqlmap.groupEnable", params);
	}

	@Override
	public int groupDisable(HashMap<String, String> params) {
		return update("group_sqlmap.groupDisable", params);
	}

	@Override
	public List<?> exportGroupWorkers(HashMap<String, String> params) {
		return selectList("group_sqlmap.exportGroupWorkers", params);
	}

	@Override
	public int getWorkerCots(HashMap<String, String> params) {
		List list = selectList("group_sqlmap.getWorkerCots", params);
		if (list != null && list.size() > 0) {
			String cot = ((Map) list.get(0)).get("COT") + "";
			return Integer.valueOf(cot);
		}
		return 0;
	}

	@Override
	public List<?> findWorkers(HashMap<String, String> params) {
		return selectList("group_sqlmap.findWorkers", params);
	}

	@Override
	public List<?> getWorkerList(HashMap<String, String> params) {
		return selectList("group_sqlmap.getWorkerList", params);
	}
	
	@Override
	public int getWorkerListCots(HashMap<String, String> params) {
		List list = selectList("group_sqlmap.getWorkerListCots", params);
		if (list != null && list.size() > 0) {
			String cot = ((Map) list.get(0)).get("COT") + "";
			return Integer.valueOf(cot);
		}
		return 0;
	}

}
